/**
 * 
 */
package com.buaa.utils;

import java.awt.Color;

import java.awt.Font;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpSession;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartRenderingInfo;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.AxisLocation;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.entity.StandardEntityCollection;
import org.jfree.chart.labels.ItemLabelAnchor;
import org.jfree.chart.labels.ItemLabelPosition;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer3D;
import org.jfree.chart.servlet.ServletUtilities;
import org.jfree.chart.title.LegendTitle;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;
import org.jfree.ui.TextAnchor;

/**
 * @author xr s
 */
@SuppressWarnings("unused")
public class PieChart3D {

	private static final int titleSize = 16;

	private static final int labelSize = 12;

	private static final double maxLabelWidth = 0.15;// percentage

	private static final Font titleFont = new Font("黑体", Font.PLAIN, titleSize);

	private static final Font lableFont = new Font("黑体", Font.PLAIN, labelSize);

	private static final boolean isCircular = true;

	private static final Color labelBgColor = new Color(200, 250, 200);

	private static final Color labelOutlineColor = new Color(224, 248, 255);

	private static final Color shadowColor = new Color(100, 100, 255);

	private static final Color firstSecsionColor = new Color(124, 252, 0);// DeepSkyBlue

	private static final Color secondSecsionColor = new Color(255, 255, 0);// Yellow

	private static final Color thirdSecsionColor = new Color(255, 192, 2);

	private static final Color forthSecsionColor = new Color(0, 255, 255);

	private static final Color fifthSecsionColor = new Color(55, 192, 203);

	private static final Color sixthSecsionColor = new Color(255, 12, 203);

	/**
	 * 构建特定数据集
	 * 
	 * @param metaData
	 * @return
	 */
	@SuppressWarnings("rawtypes")
	private static PieDataset getDataSet(Map<String, Long> metaData) {
		DefaultPieDataset dataset = new DefaultPieDataset();
		Set set = metaData.entrySet();

		for (Iterator iterator = set.iterator(); iterator.hasNext();) {

			Map.Entry string = (Map.Entry) iterator.next();

			String key = string.getKey().toString();// 次办法获取键值对的名称
			long value = Long.parseLong(string.getValue().toString());// 次办法获取键值对的值
			dataset.setValue(key, value);
		}
		return dataset;
	}

	/**
	 * 根据数据集合生成JFreeChart对象
	 * 
	 * @param title
	 * @param piedataset
	 * @return
	 */
	private static JFreeChart createChart(String title, PieDataset piedataset) {
		JFreeChart jfreechart = ChartFactory.createPieChart3D(title, piedataset, true, false, false);

		// jfreechart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
		// 设置标题字体
		jfreechart.getTitle().setFont(titleFont);

		return jfreechart;
	}

	/**
	 * 
	 * @param title
	 * @param datas
	 * @param width
	 * @param length
	 * @param session
	 * @param pw
	 * @return
	 */
	// 生成饼状图
	@SuppressWarnings("deprecation")
	public static String generatePieChart(Map<String, Long> metaData, int width, int length, HttpSession session,
			PrintWriter pw) {
		String fileName = null;

		PieDataset pieDataset = getDataSet(metaData);
		JFreeChart chart = createChart("分类统计图", pieDataset);
		chart.setBackgroundPaint(java.awt.Color.white);

		PiePlot pPlot = (PiePlot) chart.getPlot();
		chart.getLegend().setItemFont(lableFont);
		// 设置饼图正圆
		pPlot.setCircular(isCircular);
		pPlot.setBackgroundPaint(java.awt.Color.white);
		// pPlot.setBackgroundAlpha((float)1);
		// pPlot.setForegroundAlpha(1);
		// 设置分类标签的字体及颜色
		pPlot.setLabelFont(lableFont);
		pPlot.setLabelBackgroundPaint(java.awt.Color.white);

		// 分类标签最大宽度，百分比
		pPlot.setMaximumLabelWidth(maxLabelWidth);
		// 指定 section 轮廓线的厚度
		pPlot.setSectionOutlineStroke(new java.awt.BasicStroke(0));
		// 指定 section 连接线的厚度
		pPlot.setLabelLinkStroke(new java.awt.BasicStroke(1));

		// //设置各个分类的颜色
		pPlot.setSectionPaint(0, Color.decode("#07a862"));
		pPlot.setSectionPaint(1, Color.decode("#ffc000"));
		pPlot.setSectionPaint(2, Color.decode("#ff7800"));
		pPlot.setSectionPaint(3, Color.decode("#75d3e7"));
		pPlot.setSectionPaint(4, Color.decode("#1e89cd"));
		pPlot.setSectionPaint(5, Color.decode("#b762c4"));
		//

		pPlot.setIgnoreZeroValues(true);

		pPlot.setShadowPaint(shadowColor);
		pPlot.setLabelOutlinePaint(labelOutlineColor);

		pPlot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}({1})"));
		pPlot.setBackgroundPaint(Color.decode("#eaeaea"));

		ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
		try {
			fileName = ServletUtilities.saveChartAsPNG(chart, width, length, info, session);
		} catch (IOException e) {
			e.printStackTrace();
		}
		try {
			ChartUtilities.writeImageMap(pw, fileName, info, false);
		} catch (IOException e) {
			e.printStackTrace();
		}
		pw.flush();
		return fileName;
	}

	// 生成柱状图
	@SuppressWarnings("deprecation")
	public static String generateRoChart(Map<String, Long> metaData, int width, int length, HttpSession session,
			PrintWriter pw) {
		String fileName = null;

		DefaultCategoryDataset dataset = new DefaultCategoryDataset();
		int Maxnum = 13;
		for (Map.Entry<String, Long> entry : metaData.entrySet()) {
			dataset.addValue(entry.getValue(), entry.getKey(), "");
			Maxnum--;
			if (Maxnum <= 0) {
				break;
			}
		}

		JFreeChart chart = ChartFactory.createBarChart3D("分类统计图", "", "", dataset, PlotOrientation.VERTICAL, true,
				false, false);

		CategoryPlot plot = chart.getCategoryPlot();

		// 标题 字体
		TextTitle textTitle = chart.getTitle();
		textTitle.setFont(new Font("黑体", Font.PLAIN, 16));
		textTitle.setPaint(Color.decode("#000000"));

		CategoryAxis domainAxis = plot.getDomainAxis();
		domainAxis.setTickLabelFont(new Font("sans-serif", Font.PLAIN, 14));
		domainAxis.setLabelFont(new Font("黑体", Font.PLAIN, 14));
		domainAxis.setAxisLineVisible(true);
		domainAxis.setVisible(true);

		NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis();
		numberaxis.setTickLabelFont(new Font("sans-serif", Font.PLAIN, 14));
		numberaxis.setLabelFont(new Font("黑体", Font.PLAIN, 14));
		chart.getLegend().setItemFont(new Font("黑体", Font.PLAIN, 14));

		BarRenderer3D customBarRenderer = (BarRenderer3D) plot.getRenderer();
		customBarRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());// 显示每个柱的数值
		customBarRenderer.setBaseItemLabelsVisible(true);
		// 注意：此句很关键，若无此句，那数字的显示会被覆盖，给人数字没有显示出来的问题
		customBarRenderer.setBasePositiveItemLabelPosition(
				new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));
		customBarRenderer.setItemLabelAnchorOffset(10D);// 设置柱形图上的文字偏离值
		customBarRenderer.setItemLabelsVisible(true);

		// 设定柱子上面的颜色
		customBarRenderer.setSeriesPaint(0, Color.decode("#3b00f9")); // 给series1
		// Bar
		customBarRenderer.setSeriesPaint(1, Color.decode("#00bbf9")); // 给series2
		// Bar
		customBarRenderer.setSeriesPaint(2, Color.decode("#f99800")); // 给series3
		// Bar
		customBarRenderer.setSeriesPaint(3, Color.decode("#f9df00")); // 给series4
		// Bar
		customBarRenderer.setSeriesPaint(4, Color.decode("#10daad")); // 给series5

		// 设置柱子的最大宽度
		customBarRenderer.setMaximumBarWidth(0.04);
		customBarRenderer.setItemMargin(0.000000005);
		plot.setRenderer(customBarRenderer);

		plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);// 学校显示在下端(柱子竖直)
		// 或左侧(柱子水平)
		plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // 人数显示在下端(柱子水平)
		// 或左侧(柱子竖直)
		plot.setBackgroundPaint(Color.decode("#eaeaea"));
		plot.setRangeGridlinesVisible(true);
		plot.setRangeGridlinePaint(Color.decode("#cccccc"));

		LegendTitle leg = chart.getLegend();
		leg.setItemFont(new Font("黑体", Font.BOLD, 14));

		ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
		try {
			fileName = ServletUtilities.saveChartAsPNG(chart, width, length, info, session);
		} catch (IOException e) {
			e.printStackTrace();
		}
		try {
			ChartUtilities.writeImageMap(pw, fileName, info, false);
		} catch (IOException e) {
			e.printStackTrace();
		}
		pw.flush();
		return fileName;
	}

	// 生成柱状图
	@SuppressWarnings("deprecation")
	public static String generateRoChartCp(String[][] data, int width, int length, HttpSession session,
			PrintWriter pw) {
		String fileName = null;

		DefaultCategoryDataset dataset = new DefaultCategoryDataset();

		for (int i = 0; i < data.length; i++) {
			if (data[i][0] != null && !data[i][0].equals("")) {
				dataset.addValue(Double.valueOf(data[i][1]), "单位总数", data[i][0]);
				dataset.addValue(Double.valueOf(data[i][5]), "大型仪器设备总数", data[i][0]);
				dataset.addValue(Double.valueOf(data[i][7]), "收入总额", data[i][0]);
				dataset.addValue(Double.valueOf(data[i][8]), "支出总额", data[i][0]);
				dataset.addValue(Double.valueOf(data[i][14]), "固定人员总数", data[i][0]);
			} else {
				break;
			}
		}

		JFreeChart chart = ChartFactory.createBarChart3D("数据对比图", "", "", dataset, PlotOrientation.VERTICAL, true,
				false, false);
		CategoryPlot plot = chart.getCategoryPlot();// 获得图表区域对象

		// 设置图片标题
		TextTitle textTitle = chart.getTitle();
		textTitle.setFont(new Font("黑体", Font.PLAIN, 14));
		textTitle.setPaint(Color.decode("#000000"));

		// 横坐标轴
		CategoryAxis domainAxis = plot.getDomainAxis();
		domainAxis.setTickLabelFont(new Font("黑体", Font.PLAIN, 15));
		domainAxis.setAxisLineVisible(true);
		domainAxis.setVisible(true);

		// 纵坐标轴
		NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis();
		numberaxis.setTickLabelFont(new Font("sans-serif", Font.PLAIN, 12));
		numberaxis.setLabelFont(new Font("黑体", Font.PLAIN, 12));
		// 图例
		chart.getLegend().setItemFont(new Font("黑体", Font.PLAIN, 14));

		BarRenderer3D customBarRenderer = (BarRenderer3D) plot.getRenderer();
		customBarRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());// 显示每个柱的数值
		customBarRenderer.setBaseItemLabelsVisible(true);
		// 注意：此句很关键，若无此句，那数字的显示会被覆盖，给人数字没有显示出来的问题
		customBarRenderer.setBasePositiveItemLabelPosition(
				new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));
		customBarRenderer.setItemLabelAnchorOffset(10D);// 设置柱形图上的文字偏离值
		customBarRenderer.setItemLabelsVisible(true);

		// 设定柱子上面的颜色
		customBarRenderer.setSeriesPaint(0, Color.decode("#3b00f9")); // 给series1
		// Bar
		customBarRenderer.setSeriesPaint(1, Color.decode("#00bbf9")); // 给series2
		// Bar
		customBarRenderer.setSeriesPaint(2, Color.decode("#f99800")); // 给series3
		// Bar
		customBarRenderer.setSeriesPaint(3, Color.decode("#f9df00")); // 给series4
		// Bar
		customBarRenderer.setSeriesPaint(4, Color.decode("#10daad")); // 给series5
		// Bar
		customBarRenderer.setSeriesOutlinePaint(0, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(1, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(2, Color.BLACK); // 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(3, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(4, Color.BLACK);// 边框为黑色

		// 设置柱子的最大宽度
		customBarRenderer.setMaximumBarWidth(0.04);
		customBarRenderer.setItemMargin(0.000000005);
		plot.setRenderer(customBarRenderer);
		plot.setBackgroundPaint(Color.decode("#eaeaea"));
		plot.setRangeGridlinesVisible(true);
		plot.setRangeGridlinePaint(Color.decode("#cccccc"));
		plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
		// 或左侧(柱子水平)
		plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
		// 或左侧(柱子竖直)

		ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
		try {
			fileName = ServletUtilities.saveChartAsPNG(chart, width, length, info, session);
		} catch (IOException e) {
			e.printStackTrace();
		}
		try {
			ChartUtilities.writeImageMap(pw, fileName, info, false);
		} catch (IOException e) {
			e.printStackTrace();
		}
		pw.flush();
		return fileName;
	}

	// 生成柱状图
	@SuppressWarnings("deprecation")
	public static String generateRoChartdxyqcp(String[][] data, int width, int length, HttpSession session,
			PrintWriter pw) {
		String fileName = null;

		DefaultCategoryDataset dataset = new DefaultCategoryDataset();

		for (int i = 0; i < data.length; i++) {
			if (data[i][0] != null && !data[i][0].equals("")) {
				dataset.addValue(Double.valueOf(data[i][1]), "大型仪器总数", data[i][0]);
				dataset.addValue(Double.valueOf(data[i][2]), "大型仪器总原值", data[i][0]);
			} else {
				break;
			}
		}

		JFreeChart chart = ChartFactory.createBarChart3D("数据对比图", "", "", dataset, PlotOrientation.VERTICAL, true,
				false, false);
		CategoryPlot plot = chart.getCategoryPlot();// 获得图表区域对象

		// 设置图片标题
		TextTitle textTitle = chart.getTitle();
		textTitle.setFont(new Font("黑体", Font.PLAIN, 14));
		textTitle.setPaint(Color.decode("#000000"));

		// 横坐标轴
		CategoryAxis domainAxis = plot.getDomainAxis();
		domainAxis.setTickLabelFont(new Font("黑体", Font.PLAIN, 15));
		domainAxis.setAxisLineVisible(true);
		domainAxis.setVisible(true);

		// 纵坐标轴
		NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis();
		numberaxis.setTickLabelFont(new Font("sans-serif", Font.PLAIN, 12));
		numberaxis.setLabelFont(new Font("黑体", Font.PLAIN, 12));
		// 图例
		chart.getLegend().setItemFont(new Font("黑体", Font.PLAIN, 14));

		BarRenderer3D customBarRenderer = (BarRenderer3D) plot.getRenderer();
		customBarRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());// 显示每个柱的数值
		customBarRenderer.setBaseItemLabelsVisible(true);
		// 注意：此句很关键，若无此句，那数字的显示会被覆盖，给人数字没有显示出来的问题
		customBarRenderer.setBasePositiveItemLabelPosition(
				new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));
		customBarRenderer.setItemLabelAnchorOffset(10D);// 设置柱形图上的文字偏离值
		customBarRenderer.setItemLabelsVisible(true);

		// 设定柱子上面的颜色
		customBarRenderer.setSeriesPaint(0, Color.decode("#3b00f9")); // 给series1
		// Bar
		customBarRenderer.setSeriesPaint(1, Color.decode("#00bbf9")); // 给series2
		// Bar
		customBarRenderer.setSeriesPaint(2, Color.decode("#f99800")); // 给series3
		// Bar
		customBarRenderer.setSeriesPaint(3, Color.decode("#f9df00")); // 给series4
		// Bar
		customBarRenderer.setSeriesPaint(4, Color.decode("#10daad")); // 给series5
		// Bar
		customBarRenderer.setSeriesOutlinePaint(0, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(1, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(2, Color.BLACK); // 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(3, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(4, Color.BLACK);// 边框为黑色

		// 设置柱子的最大宽度
		customBarRenderer.setMaximumBarWidth(0.04);
		customBarRenderer.setItemMargin(0.000000005);
		plot.setRenderer(customBarRenderer);
		plot.setBackgroundPaint(Color.decode("#eaeaea"));
		plot.setRangeGridlinesVisible(true);
		plot.setRangeGridlinePaint(Color.decode("#cccccc"));
		plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
		// 或左侧(柱子水平)
		plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
		// 或左侧(柱子竖直)

		ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
		try {
			fileName = ServletUtilities.saveChartAsPNG(chart, width, length, info, session);
		} catch (IOException e) {
			e.printStackTrace();
		}
		try {
			ChartUtilities.writeImageMap(pw, fileName, info, false);
		} catch (IOException e) {
			e.printStackTrace();
		}
		pw.flush();
		return fileName;
	}
	
	// 生成柱状图
		@SuppressWarnings("deprecation")
		public static String generateRoChartxmcp(String[][] data, int width, int length, HttpSession session,
				PrintWriter pw) {
			String fileName = null;

			DefaultCategoryDataset dataset = new DefaultCategoryDataset();

			for (int i = 0; i < data.length; i++) {
				if (data[i][0] != null && !data[i][0].equals("")) {
					dataset.addValue(Double.valueOf(data[i][1]), "化学", data[i][0]);
					dataset.addValue(Double.valueOf(data[i][2]), "其他", data[i][0]);
				} else {
					break;
				}
			}

			JFreeChart chart = ChartFactory.createBarChart3D("数据对比图", "", "", dataset, PlotOrientation.VERTICAL, true,
					false, false);
			CategoryPlot plot = chart.getCategoryPlot();// 获得图表区域对象

			// 设置图片标题
			TextTitle textTitle = chart.getTitle();
			textTitle.setFont(new Font("黑体", Font.PLAIN, 14));
			textTitle.setPaint(Color.decode("#000000"));

			// 横坐标轴
			CategoryAxis domainAxis = plot.getDomainAxis();
			domainAxis.setTickLabelFont(new Font("黑体", Font.PLAIN, 15));
			domainAxis.setAxisLineVisible(true);
			domainAxis.setVisible(true);

			// 纵坐标轴
			NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis();
			numberaxis.setTickLabelFont(new Font("sans-serif", Font.PLAIN, 12));
			numberaxis.setLabelFont(new Font("黑体", Font.PLAIN, 12));
			// 图例
			chart.getLegend().setItemFont(new Font("黑体", Font.PLAIN, 14));

			BarRenderer3D customBarRenderer = (BarRenderer3D) plot.getRenderer();
			customBarRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());// 显示每个柱的数值
			customBarRenderer.setBaseItemLabelsVisible(true);
			// 注意：此句很关键，若无此句，那数字的显示会被覆盖，给人数字没有显示出来的问题
			customBarRenderer.setBasePositiveItemLabelPosition(
					new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));
			customBarRenderer.setItemLabelAnchorOffset(10D);// 设置柱形图上的文字偏离值
			customBarRenderer.setItemLabelsVisible(true);

			// 设定柱子上面的颜色
			customBarRenderer.setSeriesPaint(0, Color.decode("#3b00f9")); // 给series1
			// Bar
			customBarRenderer.setSeriesPaint(1, Color.decode("#00bbf9")); // 给series2
			// Bar
			customBarRenderer.setSeriesPaint(2, Color.decode("#f99800")); // 给series3
			// Bar
			customBarRenderer.setSeriesPaint(3, Color.decode("#f9df00")); // 给series4
			// Bar
			customBarRenderer.setSeriesPaint(4, Color.decode("#10daad")); // 给series5
			// Bar
			customBarRenderer.setSeriesOutlinePaint(0, Color.BLACK);// 边框为黑色
			customBarRenderer.setSeriesOutlinePaint(1, Color.BLACK);// 边框为黑色
			customBarRenderer.setSeriesOutlinePaint(2, Color.BLACK); // 边框为黑色
			customBarRenderer.setSeriesOutlinePaint(3, Color.BLACK);// 边框为黑色
			customBarRenderer.setSeriesOutlinePaint(4, Color.BLACK);// 边框为黑色

			// 设置柱子的最大宽度
			customBarRenderer.setMaximumBarWidth(0.04);
			customBarRenderer.setItemMargin(0.000000005);
			plot.setRenderer(customBarRenderer);
			plot.setBackgroundPaint(Color.decode("#eaeaea"));
			plot.setRangeGridlinesVisible(true);
			plot.setRangeGridlinePaint(Color.decode("#cccccc"));
			plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
			// 或左侧(柱子水平)
			plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
			// 或左侧(柱子竖直)

			ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
			try {
				fileName = ServletUtilities.saveChartAsPNG(chart, width, length, info, session);
			} catch (IOException e) {
				e.printStackTrace();
			}
			try {
				ChartUtilities.writeImageMap(pw, fileName, info, false);
			} catch (IOException e) {
				e.printStackTrace();
			}
			pw.flush();
			return fileName;
		}

	// 生成柱状图
	@SuppressWarnings("deprecation")
	public static String generateRoChartrycp(String[][] data, int width, int length, HttpSession session,
			PrintWriter pw) {
		String fileName = null;

		DefaultCategoryDataset dataset = new DefaultCategoryDataset();

		for (int i = 0; i < data.length; i++) {
			if (data[i][0] != null && !data[i][0].equals("")) {
				dataset.addValue(Double.valueOf(data[i][1]), "正高级人数", data[i][0]);
				dataset.addValue(Double.valueOf(data[i][2]), "副高级人数", data[i][0]);
				dataset.addValue(Double.valueOf(data[i][3]), "中级人数", data[i][0]);
			} else {
				break;
			}
		}

		JFreeChart chart = ChartFactory.createBarChart3D("数据对比图", "", "", dataset, PlotOrientation.VERTICAL, true,
				false, false);
		CategoryPlot plot = chart.getCategoryPlot();// 获得图表区域对象

		// 设置图片标题
		TextTitle textTitle = chart.getTitle();
		textTitle.setFont(new Font("黑体", Font.PLAIN, 14));
		textTitle.setPaint(Color.decode("#000000"));

		// 横坐标轴
		CategoryAxis domainAxis = plot.getDomainAxis();
		domainAxis.setTickLabelFont(new Font("黑体", Font.PLAIN, 15));
		domainAxis.setAxisLineVisible(true);
		domainAxis.setVisible(true);

		// 纵坐标轴
		NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis();
		numberaxis.setTickLabelFont(new Font("sans-serif", Font.PLAIN, 12));
		numberaxis.setLabelFont(new Font("黑体", Font.PLAIN, 12));
		// 图例
		chart.getLegend().setItemFont(new Font("黑体", Font.PLAIN, 14));

		BarRenderer3D customBarRenderer = (BarRenderer3D) plot.getRenderer();
		customBarRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());// 显示每个柱的数值
		customBarRenderer.setBaseItemLabelsVisible(true);
		// 注意：此句很关键，若无此句，那数字的显示会被覆盖，给人数字没有显示出来的问题
		customBarRenderer.setBasePositiveItemLabelPosition(
				new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));
		customBarRenderer.setItemLabelAnchorOffset(10D);// 设置柱形图上的文字偏离值
		customBarRenderer.setItemLabelsVisible(true);

		// 设定柱子上面的颜色
		customBarRenderer.setSeriesPaint(0, Color.decode("#3b00f9")); // 给series1
		// Bar
		customBarRenderer.setSeriesPaint(1, Color.decode("#00bbf9")); // 给series2
		// Bar
		customBarRenderer.setSeriesPaint(2, Color.decode("#f99800")); // 给series3
		// Bar
		customBarRenderer.setSeriesPaint(3, Color.decode("#f9df00")); // 给series4
		// Bar
		customBarRenderer.setSeriesPaint(4, Color.decode("#10daad")); // 给series5
		// Bar
		customBarRenderer.setSeriesOutlinePaint(0, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(1, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(2, Color.BLACK); // 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(3, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(4, Color.BLACK);// 边框为黑色

		// 设置柱子的最大宽度
		customBarRenderer.setMaximumBarWidth(0.04);
		customBarRenderer.setItemMargin(0.000000005);
		plot.setRenderer(customBarRenderer);
		plot.setBackgroundPaint(Color.decode("#eaeaea"));
		plot.setRangeGridlinesVisible(true);
		plot.setRangeGridlinePaint(Color.decode("#cccccc"));
		plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
		// 或左侧(柱子水平)
		plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
		// 或左侧(柱子竖直)

		ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
		try {
			fileName = ServletUtilities.saveChartAsPNG(chart, width, length, info, session);
		} catch (IOException e) {
			e.printStackTrace();
		}
		try {
			ChartUtilities.writeImageMap(pw, fileName, info, false);
		} catch (IOException e) {
			e.printStackTrace();
		}
		pw.flush();
		return fileName;
	}

	// 生成柱状图
	@SuppressWarnings("deprecation")
	public static String generateRoChartcwcp(String[][] data, int width, int length, HttpSession session,
			PrintWriter pw) {
		String fileName = null;

		DefaultCategoryDataset dataset = new DefaultCategoryDataset();

		for (int i = 0; i < data.length; i++) {
			if (data[i][0] != null && !data[i][0].equals("")) {
				dataset.addValue(Double.valueOf(data[i][1]), "当年科技活动经费收入", data[i][0]);
				dataset.addValue(Double.valueOf(data[i][2]), "当年科技活动经费支出", data[i][0]);
				dataset.addValue(Double.valueOf(data[i][3]), "来自政府", data[i][0]);
				dataset.addValue(Double.valueOf(data[i][4]), "来自中央财政", data[i][0]);
				dataset.addValue(Double.valueOf(data[i][5]), "来自省级财政", data[i][0]);
				dataset.addValue(Double.valueOf(data[i][6]), "来自地市财政", data[i][0]);
				dataset.addValue(Double.valueOf(data[i][7]), "仪器设备购置费", data[i][0]);
			} else {
				break;
			}
		}

		JFreeChart chart = ChartFactory.createBarChart3D("数据对比图", "", "", dataset, PlotOrientation.VERTICAL, true,
				false, false);
		CategoryPlot plot = chart.getCategoryPlot();// 获得图表区域对象

		// 设置图片标题
		TextTitle textTitle = chart.getTitle();
		textTitle.setFont(new Font("黑体", Font.PLAIN, 14));
		textTitle.setPaint(Color.decode("#000000"));

		// 横坐标轴
		CategoryAxis domainAxis = plot.getDomainAxis();
		domainAxis.setTickLabelFont(new Font("黑体", Font.PLAIN, 15));
		domainAxis.setAxisLineVisible(true);
		domainAxis.setVisible(true);

		// 纵坐标轴
		NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis();
		numberaxis.setTickLabelFont(new Font("sans-serif", Font.PLAIN, 12));
		numberaxis.setLabelFont(new Font("黑体", Font.PLAIN, 12));
		// 图例
		chart.getLegend().setItemFont(new Font("黑体", Font.PLAIN, 14));

		BarRenderer3D customBarRenderer = (BarRenderer3D) plot.getRenderer();
		customBarRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());// 显示每个柱的数值
		customBarRenderer.setBaseItemLabelsVisible(true);
		// 注意：此句很关键，若无此句，那数字的显示会被覆盖，给人数字没有显示出来的问题
		customBarRenderer.setBasePositiveItemLabelPosition(
				new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));
		customBarRenderer.setItemLabelAnchorOffset(10D);// 设置柱形图上的文字偏离值
		customBarRenderer.setItemLabelsVisible(true);

		// 设定柱子上面的颜色
		customBarRenderer.setSeriesPaint(0, Color.decode("#3b00f9")); // 给series1
		// Bar
		customBarRenderer.setSeriesPaint(1, Color.decode("#00bbf9")); // 给series2
		// Bar
		customBarRenderer.setSeriesPaint(2, Color.decode("#f99800")); // 给series3
		// Bar
		customBarRenderer.setSeriesPaint(3, Color.decode("#f9df00")); // 给series4
		// Bar
		customBarRenderer.setSeriesPaint(4, Color.decode("#10daad")); // 给series5
		// Bar
		customBarRenderer.setSeriesOutlinePaint(0, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(1, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(2, Color.BLACK); // 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(3, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(4, Color.BLACK);// 边框为黑色

		// 设置柱子的最大宽度
		customBarRenderer.setMaximumBarWidth(0.04);
		customBarRenderer.setItemMargin(0.000000005);
		plot.setRenderer(customBarRenderer);
		plot.setBackgroundPaint(Color.decode("#eaeaea"));
		plot.setRangeGridlinesVisible(true);
		plot.setRangeGridlinePaint(Color.decode("#cccccc"));
		plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
		// 或左侧(柱子水平)
		plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
		// 或左侧(柱子竖直)

		ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
		try {
			fileName = ServletUtilities.saveChartAsPNG(chart, width, length, info, session);
		} catch (IOException e) {
			e.printStackTrace();
		}
		try {
			ChartUtilities.writeImageMap(pw, fileName, info, false);
		} catch (IOException e) {
			e.printStackTrace();
		}
		pw.flush();
		return fileName;
	}

	// 生成柱状图
	@SuppressWarnings("deprecation")
	public static String generateRoChartdwcp(String[][] data, int width, int length, HttpSession session,
			PrintWriter pw) {
		String fileName = null;

		DefaultCategoryDataset dataset = new DefaultCategoryDataset();

		for (int i = 0; i < data.length; i++) {
			if (data[i][0] != null && !data[i][0].equals("")) {
				dataset.addValue(Double.valueOf(data[i][1]), "普通机构", data[i][0]);
				dataset.addValue(Double.valueOf(data[i][2]), "加盟机构", data[i][0]);
			} else {
				break;
			}
		}

		JFreeChart chart = ChartFactory.createBarChart3D("数据对比图", "", "", dataset, PlotOrientation.VERTICAL, true,
				false, false);
		CategoryPlot plot = chart.getCategoryPlot();// 获得图表区域对象

		// 设置图片标题
		TextTitle textTitle = chart.getTitle();
		textTitle.setFont(new Font("黑体", Font.PLAIN, 14));
		textTitle.setPaint(Color.decode("#000000"));

		// 横坐标轴
		CategoryAxis domainAxis = plot.getDomainAxis();
		domainAxis.setTickLabelFont(new Font("黑体", Font.PLAIN, 15));
		domainAxis.setAxisLineVisible(true);
		domainAxis.setVisible(true);

		// 纵坐标轴
		NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis();
		numberaxis.setTickLabelFont(new Font("sans-serif", Font.PLAIN, 12));
		numberaxis.setLabelFont(new Font("黑体", Font.PLAIN, 12));
		// 图例
		chart.getLegend().setItemFont(new Font("黑体", Font.PLAIN, 14));

		BarRenderer3D customBarRenderer = (BarRenderer3D) plot.getRenderer();
		customBarRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());// 显示每个柱的数值
		customBarRenderer.setBaseItemLabelsVisible(true);
		// 注意：此句很关键，若无此句，那数字的显示会被覆盖，给人数字没有显示出来的问题
		customBarRenderer.setBasePositiveItemLabelPosition(
				new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));
		customBarRenderer.setItemLabelAnchorOffset(10D);// 设置柱形图上的文字偏离值
		customBarRenderer.setItemLabelsVisible(true);

		// 设定柱子上面的颜色
		customBarRenderer.setSeriesPaint(0, Color.decode("#3b00f9")); // 给series1
		// Bar
		customBarRenderer.setSeriesPaint(1, Color.decode("#00bbf9")); // 给series2
		// Bar
		customBarRenderer.setSeriesPaint(2, Color.decode("#f99800")); // 给series3
		// Bar
		customBarRenderer.setSeriesPaint(3, Color.decode("#f9df00")); // 给series4
		// Bar
		customBarRenderer.setSeriesPaint(4, Color.decode("#10daad")); // 给series5
		// Bar
		customBarRenderer.setSeriesOutlinePaint(0, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(1, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(2, Color.BLACK); // 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(3, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(4, Color.BLACK);// 边框为黑色

		// 设置柱子的最大宽度
		customBarRenderer.setMaximumBarWidth(0.04);
		customBarRenderer.setItemMargin(0.000000005);
		plot.setRenderer(customBarRenderer);
		plot.setBackgroundPaint(Color.decode("#eaeaea"));
		plot.setRangeGridlinesVisible(true);
		plot.setRangeGridlinePaint(Color.decode("#cccccc"));
		plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
		// 或左侧(柱子水平)
		plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
		// 或左侧(柱子竖直)

		ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
		try {
			fileName = ServletUtilities.saveChartAsPNG(chart, width, length, info, session);
		} catch (IOException e) {
			e.printStackTrace();
		}
		try {
			ChartUtilities.writeImageMap(pw, fileName, info, false);
		} catch (IOException e) {
			e.printStackTrace();
		}
		pw.flush();
		return fileName;
	}

	// 生成柱状图
	@SuppressWarnings("deprecation")
	public static String generateRoChartbcjgcp(String[][] data, int width, int length, HttpSession session,
			PrintWriter pw) {
		String fileName = null;

		DefaultCategoryDataset dataset = new DefaultCategoryDataset();

		for (int i = 0; i < data.length; i++) {
			if (data[i][0] != null && !data[i][0].equals("")) {
				dataset.addValue(Double.valueOf(data[i][1]), "科研机构", data[i][0]);
				dataset.addValue(Double.valueOf(data[i][2]), "高等学校", data[i][0]);
				dataset.addValue(Double.valueOf(data[i][3]), "国有控股企业", data[i][0]);
				dataset.addValue(Double.valueOf(data[i][4]), "民营企业", data[i][0]);
				dataset.addValue(Double.valueOf(data[i][5]), "其他企业", data[i][0]);
			} else {
				break;
			}
		}

		JFreeChart chart = ChartFactory.createBarChart3D("数据对比图", "", "", dataset, PlotOrientation.VERTICAL, true,
				false, false);
		CategoryPlot plot = chart.getCategoryPlot();// 获得图表区域对象

		// 设置图片标题
		TextTitle textTitle = chart.getTitle();
		textTitle.setFont(new Font("黑体", Font.PLAIN, 14));
		textTitle.setPaint(Color.decode("#000000"));

		// 横坐标轴
		CategoryAxis domainAxis = plot.getDomainAxis();
		domainAxis.setTickLabelFont(new Font("黑体", Font.PLAIN, 15));
		domainAxis.setAxisLineVisible(true);
		domainAxis.setVisible(true);

		// 纵坐标轴
		NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis();
		numberaxis.setTickLabelFont(new Font("sans-serif", Font.PLAIN, 12));
		numberaxis.setLabelFont(new Font("黑体", Font.PLAIN, 12));
		// 图例
		chart.getLegend().setItemFont(new Font("黑体", Font.PLAIN, 14));

		BarRenderer3D customBarRenderer = (BarRenderer3D) plot.getRenderer();
		customBarRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());// 显示每个柱的数值
		customBarRenderer.setBaseItemLabelsVisible(true);
		// 注意：此句很关键，若无此句，那数字的显示会被覆盖，给人数字没有显示出来的问题
		customBarRenderer.setBasePositiveItemLabelPosition(
				new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));
		customBarRenderer.setItemLabelAnchorOffset(10D);// 设置柱形图上的文字偏离值
		customBarRenderer.setItemLabelsVisible(true);

		// 设定柱子上面的颜色
		customBarRenderer.setSeriesPaint(0, Color.decode("#3b00f9")); // 给series1
		// Bar
		customBarRenderer.setSeriesPaint(1, Color.decode("#00bbf9")); // 给series2
		// Bar
		customBarRenderer.setSeriesPaint(2, Color.decode("#f99800")); // 给series3
		// Bar
		customBarRenderer.setSeriesPaint(3, Color.decode("#f9df00")); // 给series4
		// Bar
		customBarRenderer.setSeriesPaint(4, Color.decode("#10daad")); // 给series5
		// Bar
		customBarRenderer.setSeriesOutlinePaint(0, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(1, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(2, Color.BLACK); // 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(3, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(4, Color.BLACK);// 边框为黑色

		// 设置柱子的最大宽度
		customBarRenderer.setMaximumBarWidth(0.04);
		customBarRenderer.setItemMargin(0.000000005);
		plot.setRenderer(customBarRenderer);
		plot.setBackgroundPaint(Color.decode("#eaeaea"));
		plot.setRangeGridlinesVisible(true);
		plot.setRangeGridlinePaint(Color.decode("#cccccc"));
		plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
		// 或左侧(柱子水平)
		plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
		// 或左侧(柱子竖直)

		ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
		try {
			fileName = ServletUtilities.saveChartAsPNG(chart, width, length, info, session);
		} catch (IOException e) {
			e.printStackTrace();
		}
		try {
			ChartUtilities.writeImageMap(pw, fileName, info, false);
		} catch (IOException e) {
			e.printStackTrace();
		}
		pw.flush();
		return fileName;
	}

	// 生成柱状图
	@SuppressWarnings("deprecation")
	public static String generateRoChartsyjdcp(String[][] data, int width, int length, HttpSession session,
			PrintWriter pw) {
		String fileName = null;

		DefaultCategoryDataset dataset = new DefaultCategoryDataset();

		for (int i = 0; i < data.length; i++) {
			if (data[i][0] != null && !data[i][0].equals("")) {
				dataset.addValue(Double.valueOf(data[i][1]), "国家级", data[i][0]);
				dataset.addValue(Double.valueOf(data[i][2]), "部级", data[i][0]);
				dataset.addValue(Double.valueOf(data[i][3]), "省级", data[i][0]);
			} else {
				break;
			}
		}

		JFreeChart chart = ChartFactory.createBarChart3D("数据对比图", "", "", dataset, PlotOrientation.VERTICAL, true,
				false, false);
		CategoryPlot plot = chart.getCategoryPlot();// 获得图表区域对象

		// 设置图片标题
		TextTitle textTitle = chart.getTitle();
		textTitle.setFont(new Font("黑体", Font.PLAIN, 14));
		textTitle.setPaint(Color.decode("#000000"));

		// 横坐标轴
		CategoryAxis domainAxis = plot.getDomainAxis();
		domainAxis.setTickLabelFont(new Font("黑体", Font.PLAIN, 15));
		domainAxis.setAxisLineVisible(true);
		domainAxis.setVisible(true);

		// 纵坐标轴
		NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis();
		numberaxis.setTickLabelFont(new Font("sans-serif", Font.PLAIN, 12));
		numberaxis.setLabelFont(new Font("黑体", Font.PLAIN, 12));
		// 图例
		chart.getLegend().setItemFont(new Font("黑体", Font.PLAIN, 14));

		BarRenderer3D customBarRenderer = (BarRenderer3D) plot.getRenderer();
		customBarRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());// 显示每个柱的数值
		customBarRenderer.setBaseItemLabelsVisible(true);
		// 注意：此句很关键，若无此句，那数字的显示会被覆盖，给人数字没有显示出来的问题
		customBarRenderer.setBasePositiveItemLabelPosition(
				new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));
		customBarRenderer.setItemLabelAnchorOffset(10D);// 设置柱形图上的文字偏离值
		customBarRenderer.setItemLabelsVisible(true);

		// 设定柱子上面的颜色
		customBarRenderer.setSeriesPaint(0, Color.decode("#3b00f9")); // 给series1
		// Bar
		customBarRenderer.setSeriesPaint(1, Color.decode("#00bbf9")); // 给series2
		// Bar
		customBarRenderer.setSeriesPaint(2, Color.decode("#f99800")); // 给series3
		// Bar
		customBarRenderer.setSeriesPaint(3, Color.decode("#f9df00")); // 给series4
		// Bar
		customBarRenderer.setSeriesPaint(4, Color.decode("#10daad")); // 给series5
		// Bar
		customBarRenderer.setSeriesOutlinePaint(0, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(1, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(2, Color.BLACK); // 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(3, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(4, Color.BLACK);// 边框为黑色

		// 设置柱子的最大宽度
		customBarRenderer.setMaximumBarWidth(0.04);
		customBarRenderer.setItemMargin(0.000000005);
		plot.setRenderer(customBarRenderer);
		plot.setBackgroundPaint(Color.decode("#eaeaea"));
		plot.setRangeGridlinesVisible(true);
		plot.setRangeGridlinePaint(Color.decode("#cccccc"));
		plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
		// 或左侧(柱子水平)
		plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
		// 或左侧(柱子竖直)

		ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
		try {
			fileName = ServletUtilities.saveChartAsPNG(chart, width, length, info, session);
		} catch (IOException e) {
			e.printStackTrace();
		}
		try {
			ChartUtilities.writeImageMap(pw, fileName, info, false);
		} catch (IOException e) {
			e.printStackTrace();
		}
		pw.flush();
		return fileName;
	}

	// 生成柱状图
	@SuppressWarnings("deprecation")
	public static String generateRoChartktcp(String[][] data, int width, int length, HttpSession session,
			PrintWriter pw) {
		String fileName = null;

		DefaultCategoryDataset dataset = new DefaultCategoryDataset();

		for (int i = 0; i < data.length; i++) {
			if (data[i][0] != null && !data[i][0].equals("")) {
				dataset.addValue(Double.valueOf(data[i][1]), "课题总数", data[i][0]);
			} else {
				break;
			}
		}

		JFreeChart chart = ChartFactory.createBarChart3D("数据对比图", "", "", dataset, PlotOrientation.VERTICAL, true,
				false, false);
		CategoryPlot plot = chart.getCategoryPlot();// 获得图表区域对象

		// 设置图片标题
		TextTitle textTitle = chart.getTitle();
		textTitle.setFont(new Font("黑体", Font.PLAIN, 14));
		textTitle.setPaint(Color.decode("#000000"));

		// 横坐标轴
		CategoryAxis domainAxis = plot.getDomainAxis();
		domainAxis.setTickLabelFont(new Font("黑体", Font.PLAIN, 15));
		domainAxis.setAxisLineVisible(true);
		domainAxis.setVisible(true);

		// 纵坐标轴
		NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis();
		numberaxis.setTickLabelFont(new Font("sans-serif", Font.PLAIN, 12));
		numberaxis.setLabelFont(new Font("黑体", Font.PLAIN, 12));
		// 图例
		chart.getLegend().setItemFont(new Font("黑体", Font.PLAIN, 14));

		BarRenderer3D customBarRenderer = (BarRenderer3D) plot.getRenderer();
		customBarRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());// 显示每个柱的数值
		customBarRenderer.setBaseItemLabelsVisible(true);
		// 注意：此句很关键，若无此句，那数字的显示会被覆盖，给人数字没有显示出来的问题
		customBarRenderer.setBasePositiveItemLabelPosition(
				new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));
		customBarRenderer.setItemLabelAnchorOffset(10D);// 设置柱形图上的文字偏离值
		customBarRenderer.setItemLabelsVisible(true);

		// 设定柱子上面的颜色
		customBarRenderer.setSeriesPaint(0, Color.decode("#3b00f9")); // 给series1
		// Bar
		customBarRenderer.setSeriesPaint(1, Color.decode("#00bbf9")); // 给series2
		// Bar
		customBarRenderer.setSeriesPaint(2, Color.decode("#f99800")); // 给series3
		// Bar
		customBarRenderer.setSeriesPaint(3, Color.decode("#f9df00")); // 给series4
		// Bar
		customBarRenderer.setSeriesPaint(4, Color.decode("#10daad")); // 给series5
		// Bar
		customBarRenderer.setSeriesOutlinePaint(0, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(1, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(2, Color.BLACK); // 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(3, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(4, Color.BLACK);// 边框为黑色

		// 设置柱子的最大宽度
		customBarRenderer.setMaximumBarWidth(0.04);
		customBarRenderer.setItemMargin(0.000000005);
		plot.setRenderer(customBarRenderer);
		plot.setBackgroundPaint(Color.decode("#eaeaea"));
		plot.setRangeGridlinesVisible(true);
		plot.setRangeGridlinePaint(Color.decode("#cccccc"));
		plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
		// 或左侧(柱子水平)
		plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
		// 或左侧(柱子竖直)

		ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
		try {
			fileName = ServletUtilities.saveChartAsPNG(chart, width, length, info, session);
		} catch (IOException e) {
			e.printStackTrace();
		}
		try {
			ChartUtilities.writeImageMap(pw, fileName, info, false);
		} catch (IOException e) {
			e.printStackTrace();
		}
		pw.flush();
		return fileName;
	}

	// 生成柱状图
	@SuppressWarnings("deprecation")
	public static String generateRoChartcgcp(String[][] data, int width, int length, HttpSession session,
			PrintWriter pw) {
		String fileName = null;

		DefaultCategoryDataset dataset = new DefaultCategoryDataset();

		for (int i = 0; i < data.length; i++) {
			if (data[i][0] != null && !data[i][0].equals("")) {
				dataset.addValue(Double.valueOf(data[i][1]), "成果总数", data[i][0]);
			} else {
				break;
			}
		}

		JFreeChart chart = ChartFactory.createBarChart3D("数据对比图", "", "", dataset, PlotOrientation.VERTICAL, true,
				false, false);
		CategoryPlot plot = chart.getCategoryPlot();// 获得图表区域对象

		// 设置图片标题
		TextTitle textTitle = chart.getTitle();
		textTitle.setFont(new Font("黑体", Font.PLAIN, 14));
		textTitle.setPaint(Color.decode("#000000"));

		// 横坐标轴
		CategoryAxis domainAxis = plot.getDomainAxis();
		domainAxis.setTickLabelFont(new Font("黑体", Font.PLAIN, 15));
		domainAxis.setAxisLineVisible(true);
		domainAxis.setVisible(true);

		// 纵坐标轴
		NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis();
		numberaxis.setTickLabelFont(new Font("sans-serif", Font.PLAIN, 12));
		numberaxis.setLabelFont(new Font("黑体", Font.PLAIN, 12));
		// 图例
		chart.getLegend().setItemFont(new Font("黑体", Font.PLAIN, 14));

		BarRenderer3D customBarRenderer = (BarRenderer3D) plot.getRenderer();
		customBarRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());// 显示每个柱的数值
		customBarRenderer.setBaseItemLabelsVisible(true);
		// 注意：此句很关键，若无此句，那数字的显示会被覆盖，给人数字没有显示出来的问题
		customBarRenderer.setBasePositiveItemLabelPosition(
				new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));
		customBarRenderer.setItemLabelAnchorOffset(10D);// 设置柱形图上的文字偏离值
		customBarRenderer.setItemLabelsVisible(true);

		// 设定柱子上面的颜色
		customBarRenderer.setSeriesPaint(0, Color.decode("#3b00f9")); // 给series1
		// Bar
		customBarRenderer.setSeriesPaint(1, Color.decode("#00bbf9")); // 给series2
		// Bar
		customBarRenderer.setSeriesPaint(2, Color.decode("#f99800")); // 给series3
		// Bar
		customBarRenderer.setSeriesPaint(3, Color.decode("#f9df00")); // 给series4
		// Bar
		customBarRenderer.setSeriesPaint(4, Color.decode("#10daad")); // 给series5
		// Bar
		customBarRenderer.setSeriesOutlinePaint(0, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(1, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(2, Color.BLACK); // 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(3, Color.BLACK);// 边框为黑色
		customBarRenderer.setSeriesOutlinePaint(4, Color.BLACK);// 边框为黑色

		// 设置柱子的最大宽度
		customBarRenderer.setMaximumBarWidth(0.04);
		customBarRenderer.setItemMargin(0.000000005);
		plot.setRenderer(customBarRenderer);
		plot.setBackgroundPaint(Color.decode("#eaeaea"));
		plot.setRangeGridlinesVisible(true);
		plot.setRangeGridlinePaint(Color.decode("#cccccc"));
		plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
		// 或左侧(柱子水平)
		plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
		// 或左侧(柱子竖直)

		ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
		try {
			fileName = ServletUtilities.saveChartAsPNG(chart, width, length, info, session);
		} catch (IOException e) {
			e.printStackTrace();
		}
		try {
			ChartUtilities.writeImageMap(pw, fileName, info, false);
		} catch (IOException e) {
			e.printStackTrace();
		}
		pw.flush();
		return fileName;
	}
}
